﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ppt = Microsoft.Office.Interop.PowerPoint;
using System.Drawing;

namespace ObjectModel.PowerPoint
{
    /// <summary>
    /// A basic container for a PowerPoint shape object that holds ID and Name information
    /// after the shape is not longer accesible (e.g. after having been deleted).
    /// </summary>
    public struct ShapeInfo
    {
        public readonly int Id; // Local ID of shape within slide.
        public readonly string UniqueId; // Combination of slide ID and local shape ID.
        public readonly string Name;
        public readonly int SlideId;
        public readonly Ppt.Shape Shape;


        public ShapeInfo(Ppt.Shape shape)
        {
            Shape = shape;
            Id = shape.Id;
            SlideId = shape.GetSlide().SlideID;
            UniqueId = shape.GetUniqueID();
            Name = shape.Name;
        }

        public override bool Equals(object obj)
        {
            if (!(obj is ShapeInfo)) return false;

            return Equals((ShapeInfo)obj);
        }

        public bool Equals(ShapeInfo s)
        {
            return UniqueId == s.UniqueId;
        }

        public static bool operator ==(ShapeInfo s1, ShapeInfo s2)
        {
            return s1.Equals(s2);
        }

        public static bool operator !=(ShapeInfo s1, ShapeInfo s2)
        {
            return !(s1 == s2);
        }

        public override int GetHashCode()
        {
            return UniqueId.GetHashCode();
        }
    }
}
